package me.jessyan.armscomponent.app.mvp.ui.holder;

import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jess.arms.base.BaseHolder;

import butterknife.BindView;
import me.jessyan.armscomponent.app.R;
import me.jessyan.armscomponent.app.mvp.ui.model.LeftListBean;

public class LeftListHolder extends BaseHolder<LeftListBean> {
    @BindView(R.id.icon)
    ImageView mIcon;
    @BindView(R.id.title)
    TextView mTitle;

    private LeftListItemClickListener mListener;

    public LeftListHolder(View itemView,LeftListItemClickListener mListener) {
        super(itemView);
        this.mListener = mListener;
    }

    @Override
    public void setData(@NonNull LeftListBean leftListBean, int i) {
        if((leftListBean == null || TextUtils.isEmpty(leftListBean.getName()))) return;
        mIcon.setImageResource(leftListBean.getResource());
        mTitle.setText(leftListBean.getName());
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListener.onItemClick(leftListBean);
            }
        });
    }

    @Override
    protected void onRelease() {
//        mImageLoader.clear(mAppComponent.application(), CommonImageConfigImpl.builder()
//                .imageViews(mAvatar)
//                .build());
    }

    public interface LeftListItemClickListener{
        public void onItemClick(LeftListBean leftListBean);
    }

}
